<template>
  <div class="dy">
    <div v-for="(item, key) in comingArr" :key="key">
      <div class="riqi">{{ key }}</div>
      <ul class="dy-con">
        <li v-for="i in item" :key="i.id">
          <div class="dy-life">
            <img :src="i.img"/>
          </div>
          <div class="dy-middle">
            <h3>{{ i.nm }}</h3>
            <div><span>{{ i.wish }}</span>人想看</div>
            <div>{{ i.star }}</div>
            <div>{{ i.rt }}上映</div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "daiying",
  data() {
    return {
      comingArr: [],
    };
  },
  mounted() {
    axios.get("comming.json").then((res) => {
      console.log(res);
    });
    axios.get("daiying.json").then((res) => {
      console.log(res);
      let comingArr = res.data.coming;
      var coming = {}; //对象，保存 组装完的数组
      //一维数组转二维数组
      comingArr.forEach((item) => {
        //修改 图片的w.h 为 128.180
        item.img = item.img.replace("w.h", "128.180");
        if (coming[item.comingTitle]) {
          coming[item.comingTitle].push(item);
        } else {
          coming[item.comingTitle] = [];
          coming[item.comingTitle].push(item);
        }
      });
      this.comingArr = coming;
      console.log("待映", this.comingArr);
    });
  },
};
</script>

<style scoped>
* {
  padding: 0;
  margin: 0;
}

.dy {
  text-align: left;
}
.riqi{
  padding: 0.267rem 0.533rem 0 0.533rem;
  font-size: 0.4rem;
  color: #333;
}

.dy-con li {
  width: 100%;
  display: flex;
  flex-direction: row;
}

.dy-con li img {
  width: 64px;
  height: 90px;
}

.dy-middle {
 margin-left: 0.267rem;
  font-size: 0.4rem;
}
.dy-middle h3{
  padding-bottom: 0.027rem;
}
.dy-middle div{
  padding-bottom: 0.08rem;
  color: #666666;
}
.dy-middle span{
  color: #FAAF00;
  font-weight: bold;
}
</style>